package com.oo.array_$.case_2;

import java.util.Arrays;
import java.util.Scanner;

/**
 * NumberDemo--编写JAVA程序，接收用户输入的6个数字,
 * 分别实现将输入的数据按顺序和倒序输出，并统计所有输入数据之和
 要求：
 使用Arrays.toString()方法，实现数组数据的顺序输出
 使用循环方式，实现数组数据的倒序输出

 *
 * @author: Jovi
 * @createTime: 2017-05-11 17:30
 **/
public class NumberDemo {

    public static void main(String[] args) {
        int sum = 0;
        int[] a = new int[6];
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter 6 Numbers：");
        for (int i = 0; i < a.length; i++) {
            a[i]=sc.nextInt();
            sum += a[i];
        }
        System.out.println("Output the received data sequence：" + Arrays.toString(a));
        System.out.println("Output the received data in reverse order：");
        for (int i = 5; i >=0; i--) {
            System.out.print(a[i] + " ");
        }
        System.out.println();
        System.out.println("As the sum of the received data is " + sum);
    }
}
